
import java.util.Arrays;
import java.util.Scanner;
import java.util.Set;
import java.util.HashSet;

public class TicketIDFinder {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt(); // 读取数据行数
        Set<Integer> idSet = new HashSet<>();
        int minID = Integer.MAX_VALUE;
        int maxID = Integer.MIN_VALUE;

        // 读取所有ID并找出最小和最大ID
        for (int i = 0; i < N; i++) {
            while (scanner.hasNextInt()) {
                int id = scanner.nextInt();
                if (id < minID) minID = id;
                if (id > maxID) maxID = id;
                idSet.add(id);
            }
        }
        scanner.close();

        // 查找断号和重号
        int missingID = -1;
        int duplicateID = -1;
        for (int id = minID; id <= maxID; id++) {
            if (!idSet.contains(id)) {
                missingID = id; // 找到断号
            } else if (idSet.contains(id) && id != minID && id != maxID) {
                idSet.remove(id); // 移除已检查的ID
                if (idSet.contains(id)) {
                    duplicateID = id; // 找到重号
                }
            }
        }

        // 输出结果
        System.out.println(missingID + " " + duplicateID);
    }
}
